package tech.xiaozai.common.restful;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;

/**
 *  错误枚举
 * @author xiaozai
 * @version 1.0
 * @date 2020-08-30 16:35
 */
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
public enum ErrorValue {


    /**
     * 各枚举值，含义参考其中的description字段
     */
    UNKNOWN_ERROR(-1, "unknown_error", "未知错误"),
    SERVER_ERROR(5000, "server_error", "服务器内部异常"),
    BUSINESS_ERROR(5001, "business_error", "业务错误"),
    ILLEGAL_ARGUMENT_ERROR(5002, "illegal_argument_error", "参数错误"),
    JSON_SERIALIZATION_ERROR(5003, "json_serialization_error", "JSON序列化失败"),
    UNAUTHORIZED_ACCESS(5004, "unauthorized_access", "未经授权的访问"),
    SIGN_CHECK_ERROR(5005, "sign_check_error", "签名校验失败"),
    FEIGN_CALL_ERROR(5006, "feign_call_error", "远程调用失败");

    /**
     *  错误码
     */
    @Getter
    private Integer code;
    /**
     *  错误原因
     */
    @Getter
    private String reason;
    /**
     *  错误描述
     */
    @Getter
    private String description;

    /**
     *  构造器
     * @param code
     * @param reason
     * @param description
     */
    private ErrorValue(Integer code, String reason, String description){
        this.code = code;
        this.reason = reason;
        this.description = description;
    }



}
